/*
 * ProjectileFactory.java
 *
 * Created on 18. Mai 2007, 13:32
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package de.tor.obj.impl;

import de.tor.loaders.Level;
import de.tor.obj.AbstractProjectile;
import de.tor.obj.TorridityGameObject;
import java.awt.image.BufferedImage;
import java.util.Hashtable;

/**
 *
 * @author Charon
 */
public class ProjectileFactory {
    
    public static final int NO_PROJECTILE = -1;
    public static final int GATLING_PROJECTILE = 0;
    public static final int GATLING_PIERCER_PROJECTILE = 1;
    public static final int GATLING_SHRAPNELL_PROJECTILE = 2;
    public static final int GATLING_SHRAPNELL = 3;
    
    private static Level mLevel = null;
    private static Hashtable<Integer, BufferedImage> mProjectileSymbols = null;
    
    public static void init(Level pLevel){
        mLevel = pLevel;
        mProjectileSymbols = new Hashtable();
        mProjectileSymbols.put(NO_PROJECTILE, mLevel.getImage("resources/empty_symbol.png"));
        mProjectileSymbols.put(GATLING_PROJECTILE, mLevel.getImage(GatlingProjectile.getSymbolResourceName()));
        mProjectileSymbols.put(GATLING_SHRAPNELL_PROJECTILE, mLevel.getImage(GatlingShrapnellProjectile.getSymbolResourceName()));
        mProjectileSymbols.put(GATLING_PIERCER_PROJECTILE, mLevel.getImage(GatlingPiercerProjectile.getSymbolResourceName()));
    }
    
    public static AbstractProjectile factorProjectile(TorridityGameObject mOwner, int pType){
        switch(pType){
            case GATLING_PROJECTILE:{
                return new GatlingProjectile(mOwner, mLevel, mLevel.getImage(GatlingProjectile.getResourceName(), true));
            }case GATLING_PIERCER_PROJECTILE:{
                return new GatlingPiercerProjectile(mOwner, mLevel, mLevel.getImage(GatlingPiercerProjectile.getResourceName(), true));
            }case GATLING_SHRAPNELL_PROJECTILE:{
                return new GatlingShrapnellProjectile(mOwner, mLevel, mLevel.getImage(GatlingShrapnellProjectile.getResourceName(), true));
            }case GATLING_SHRAPNELL:{
                return new ShrapnellProjectile(mOwner, mLevel, mLevel.getImage(ShrapnellProjectile.getResourceName(), true));
            }  default:{
                return null;
            }
        }
    }
    
    public static BufferedImage getSymbol(int pType){
        return mProjectileSymbols.get(pType);
    }
    
    public static int getShotsPerSecond(int pType){
        switch(pType){
            case GATLING_PROJECTILE:{
                return GatlingProjectile.getShotsPerSecond();
            }case GATLING_PIERCER_PROJECTILE:{
                return GatlingPiercerProjectile.getShotsPerSecond();
            }case GATLING_SHRAPNELL_PROJECTILE:{
                return GatlingShrapnellProjectile.getShotsPerSecond();
            }case GATLING_SHRAPNELL:{
                return ShrapnellProjectile.getShotsPerSecond();
            } default:{
                return 120;
            }
        }
    }
}
